<script type="text/javascript">
    function updatepicture(pic) {
        document.getElementById("image_derecha").setAttribute("src", pic);
         }
    function envia_img(){
        document.form_imagen_derecha.submit();
    }
    function updatepicture_iz(pic) {
        document.getElementById("image_izquierda").setAttribute("src", pic);
         }
    function envia_img_iz(){
        document.form_imagen_izquierda.submit();
    }
    function updatepicture_fr(pic) {
        document.getElementById("image_frente").setAttribute("src", pic);
         }
    function envia_img_fr(){
        document.form_imagen_frente.submit();
    }
    function updatepicture_ba(pic) {
        document.getElementById("image_baul").setAttribute("src", pic);
         }
    function envia_img_ba(){
        document.form_imagen_baul.submit();
    }
    function updatepicture_in(pic) {
        document.getElementById("image_interior").setAttribute("src", pic);
         }
    function envia_img_in(){
        document.form_imagen_interior.submit();
    }
    function updatepicture_mo(pic) {
        document.getElementById("image_motor").setAttribute("src", pic);
         }
    function envia_img_mo(){
        document.form_imagen_motor.submit();
    }
    
    function showFields(valor){
        if (valor == 3 || valor == 2) {
            document.getElementById('divout').style.display='none';
        }else{
            document.getElementById('divout').style.display='block';
        }
    }
	function showFields(valor){
        if (valor == 0) {
            document.getElementById('divout2').style.display='none';
        }else{
            document.getElementById('divout2').style.display='block';
        }
    }
	function showFields_dominio_completo(valor){
        if (valor == 2 || valor == 3) {
            document.getElementById('dominio_completo').style.display='none';
            document.masterform.VehiclesDominio.value = "";
        }else{
            document.getElementById('dominio_completo').style.display='block';
        }
    }
	function showFields_motor_completo(valor){
        if (valor == 2 || valor == 3) {
            document.getElementById('motor_completo').style.display='none';
            document.masterform.VehiclesNroMotor.value = "";
        }else{
            document.getElementById('motor_completo').style.display='block';
        }
    }
	function showFields_chasis_completo(valor){
        if (valor == 2 || valor == 3) {
            document.getElementById('chasis_completo').style.display='none';
            document.masterform.VehiclesNroChasis.value = "";            
        }else{
            document.getElementById('chasis_completo').style.display='block';
        }
    }
	function sendForm(){

                if(jQuery("#MasterFechaDay").val()==""){
                    jQuery("#MasterFechaDay").addClass("reqdate");window.scroll(2,2);
                    return false;
                   }
		if(jQuery("#MasterFechaMonth").val()==""){
                    jQuery("#MasterFechaMonth").addClass("reqdate");window.scroll(2,2);
                    return false;
                   }
		if(jQuery("#MasterFechaYear").val()==""){
                    jQuery("#MasterFechaYear").addClass("reqdate");window.scroll(2,2);
                    return false;
                   }
		if(jQuery("#VehiclesDominio").val()=="" && (jQuery("#VehiclesDomParcial").val()=="0" || jQuery("#VehiclesDomParcial").val()=="1")){
                    jQuery("#VehiclesDominio").addClass("reqinput");window.scroll(0,0);
                    return false;
                   }
                if(jQuery("#VehiclesNroMotor").val()=="" && (jQuery("#VehiclesMotorParc").val()=="0" || jQuery("#VehiclesMotorParc").val()=="1")){                   
                    Query("#VehiclesNroMotor").addClass("reqinput3");
                    return false;
                   }
	
		if(jQuery("#VehiclesVehiclesTypesId").val()==""){
                    jQuery("#VehiclesVehiclesTypesId").addClass("reqinputsize2");window.scroll(2,2);
                    return false;
                   }
		if(jQuery("#brands").val()==""){
                    jQuery("#brands").addClass("reqinputsize2");window.scroll(0,0);
                    return false;
                   }	

		if(jQuery("#VehiclesNroChasis").val()=="" && (jQuery("#VehiclesChasisParc").val()=="0" || jQuery("#VehiclesChasisParc").val()=="1")){
                    jQuery("#VehiclesNroChasis").addClass("reqinput");window.scroll(0,0);
                    return false;
                   }
                if(jQuery("#jurisdictions").val()==""){
                    jQuery("#jurisdictions").addClass("reqinputsize2");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#provinces").val()==""){
                    jQuery("#provinces").addClass("reqinputsize2");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#charters").val()==""){
                    jQuery("#charters").addClass("reqinputsize2");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#placements").val()==""){
                    jQuery("#placements").addClass("reqinputsize2");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#courts").val()==""){
                    jQuery("#courts").addClass("reqinputsize2");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#secretaries").val()==""){
                    jQuery("#secretaries").addClass("reqinputsize2");window.scroll(0,0);
                    return false;
                   }
                if(jQuery("#CausesNroCausa").val()==""){
                    jQuery("#CausesNroCausa").addClass("reqinputsize2");window.scroll(0,0);
                    return false;
                   }
		if(jQuery("#MasterPoliceStatesId").val()==""){
                    jQuery("#MasterPoliceStatesId").addClass("reqinputsize2");window.scroll(2,2);
                    return false;
                   }
		if(jQuery("#MasterDespositsId").val()==""){
                    jQuery("#MasterDespositsId").addClass("reqinputsize2");window.scroll(2,2);
                    return false;
                   }

		if(jQuery("#derecha").val()==""){
                    jQuery("#derecha").addClass("reqinputsize2");window.scroll(2,2);
                    return false;
         	}
                if(jQuery("#izquierda").val()==""){
                    jQuery("#izquierda").addClass("reqinputsize2");window.scroll(2,2);
                    return false;
         	}
               if(jQuery("#frente").val()==""){
                    jQuery("#frente").addClass("reqinputsize2");window.scroll(2,2);
                    return false;
         	}
               if(jQuery("#baul").val()==""){
                    jQuery("#baul").addClass("reqinputsize2");window.scroll(2,2);
                    return false;
         	}
                if(jQuery("#interior").val()==""){
                    jQuery("#interior").addClass("reqinputsize2");window.scroll(2,2);
                    return false;
         	}
                if(jQuery("#motor").val()==""){
                    jQuery("#motor").addClass("reqinputsize2");window.scroll(2,2);
                    return false;
         	}
        }
</script>
<div class="masters form">
<?php $this->Html->script('prototype', array('inline' => false));?>
<?php echo $this->Form->create('Master',array('type'=>'file','name'=>'masterform','action'=>'confirma'));?>
	<h4 style="margin-top: 0px; margin-bottom: 8px;"><legend><?php __('Add Master'); ?></legend></h4>
	<fieldset>
		<div style=" margin-left:0px; width: 1000px; ">
		<div>
		<div style="padding-left:10px; padding-top:1px; width: 500px; float:left;">
		
            <fieldset>
            <h5 style="margin-top: 0px; margin-bottom: 8px;"><legend><?php __('Vehiculo'); ?></legend></h5>
			
				<span><?php 
				//echo $this->Form->input('fecha',array('dateFormat' => 'DMY', 'empty' =>'-', 'label'=>'Fecha de Secuestro', 'tabindex' =>'1'));
			         if(isset($flag)){echo $this->Form->input('fecha',array('dateFormat' => 'DMY', 'empty' =>'$parafecha', 'label'=>'Fecha de Secuestro', 'tabindex' =>'1', 'maxYear' => (date('Y') - 0) ));}
                                 else{echo $this->Form->input('fecha',array('dateFormat' => 'DMY', 'empty' =>'-', 'label'=>'Fecha de Secuestro', 'tabindex' =>'1', 'maxYear' => (date('Y') - 0) ));}
				

				
				?></span>
		        <span style="float: left;"><?php echo $this->Form->input('Vehicles.vehicles_types_id',array('label'=> 'Tipo de Vehículo','options'=>$vehicles_type,'type'=>'select','empty'=>'--Seleccione--','class' => 'imputsize2', 'tabindex' =>'2'));?></span>
				<span><?php echo $this->Form->input('Models.brands_id' , array('label'=> 'Marca','empty' => '-- Seleccione --','id'=>'brands','class' => 'inputsize2', 'tabindex' =>'3'));?></span>
				<span><?php echo $this->Form->input('Vehicles.models_id' , array('label'=> 'Modelo','empty' => '-- Seleccione --','id'=>'models','class' => 'inputsize2', 'tabindex' =>'4'));?></span>
				<br/>
				<span style="float: left;"><?php 
                                 if(isset($extranjero)){  
                                           echo $this->Form->input('Vehicles.extranjero' , array('label'=>'Dominio Extranjero','empty'=>array('0'=>'No','1'=>'Si'),'type'=>'select','selected'=>$extranjero,'class' => 'inputsize4', 'tabindex' =>'5'));
                                 }else{
                                           echo $this->Form->input('Vehicles.extranjero' , array('label'=>'Dominio Extranjero','empty'=>array('0'=>'No','1'=>'Si'),'type'=>'select','selected'=>'0','class' => 'inputsize4', 'tabindex' =>'5'));
                                 }?></span>
				<span>
                                <?php 
                                if(isset($dom_parcial)){							
                                           echo $this->Form->input('Vehicles.dom_parcial' ,array('label'=>'N° Dominio Completo','empty'=>array('0'=>'No','1'=>'Si','2'=>'Ilegible','3'=>'No Posee'),'type'=>'select','selected'=>$dom_parcial,'class' => 'inputsize4', 'tabindex' =>'6', 'onChange' => 'showFields_dominio_completo(this.value)')); 
                                }else{
                                           echo $this->Form->input('Vehicles.dom_parcial' ,array('label'=>'N° Dominio Completo','empty'=>array('0'=>'No','1'=>'Si','2'=>'Ilegible','3'=>'No Posee'),'type'=>'select','selected'=>'1','class' => 'inputsize4', 'tabindex' =>'6', 'onChange' => 'showFields_dominio_completo(this.value)' ));
                                }?>
				</span>
                <div id="dominio_completo"<?php if(isset($dom_parcial) && ($dom_parcial == 3 || $dom_parcial == 2)){echo"style='display: none;'";}?>>
				<span><?php echo $this->Form->input('Vehicles.dominio' ,array( 'label'=>'Dominio', 'tabindex' =>'7'));?></span>
				</div>
				<span style="float: left;"><?php  
				         if(isset($motor_parc)){ 
						       echo $this->Form->input('Vehicles.motor_parc' ,array('label'=>'N° Motor Completo','empty'=>array('0'=>'No','1'=>'Si','2'=>'Ilegible','3'=>'No Posee'),'type'=>'select','selected'=>$motor_parc,'class' => 'inputsize4', 'tabindex' =>'8', 'onChange' => 'showFields_motor_completo(this.value)'));
						 }else{
						       echo $this->Form->input('Vehicles.motor_parc' ,array('label'=>'N° Motor Completo','empty'=>array('0'=>'No','1'=>'Si','2'=>'Ilegible','3'=>'No Posee'),'type'=>'select','selected'=>'1','class' => 'inputsize4', 'tabindex' =>'8', 'onChange' => 'showFields_motor_completo(this.value)'));
						 }?>
				<span><?php  
						if(isset($chasis_parc)){ 
						    	echo $this->Form->input('Vehicles.chasis_parc', array('label'=>'N° Chasis Completo','empty'=>array('0'=>'No','1'=>'Si','2'=>'Ilegible','3'=>'No Posee'),'type'=>'select','selected'=>$chasis_parc,'class' => 'inputsize4', 'tabindex' =>'9', 'onChange' => 'showFields_chasis_completo(this.value)'));
				        }else{
						    	echo $this->Form->input('Vehicles.chasis_parc', array('label'=>'N° Chasis Completo','empty'=>array('0'=>'No','1'=>'Si','2'=>'Ilegible','3'=>'No Posee'),'type'=>'select','selected'=>'1','class' => 'inputsize4', 'tabindex' =>'9', 'onChange' => 'showFields_chasis_completo(this.value)'));
					    }?>
			    </span>
				<div id="motor_completo"<?php if(isset($motor_parc) && ($motor_parc == 3 || $motor_parc == 2)){echo"style='display: none;'";}?>>
				<span><?php  echo $this->Form->input('Vehicles.nro_motor' ,array('label'=>'N° Motor', 'tabindex' =>'10'));?></span>
				</div>
				<div id="chasis_completo"<?php if(isset($chasis_parc) && ($chasis_parc == 3 || $chasis_parc == 2)){echo"style='display: none;'";}?>>
				<span><?php  echo $this->Form->input('Vehicles.nro_chasis' ,array('label'=>'N° de Chasis', 'tabindex' =>'11'));?></span>
				</div>
			 </fieldset>
		</div>
		
	    <div style="padding-left:10px; padding-top:1px; width: 450px; float:left;">

            <fieldset>
            <h5 style="margin-top: 0px; margin-bottom: 8px;"><legend><?php __('Datos Judiciales'); ?></legend></h5>
			
		    <span style="padding-left: 60px;">
            <?php echo $this->Form->input('jurisdictions_id',array('id'=>'jurisdictions','empty' => '-- Seleccione --', 'label'=> 'Jurisdicción','class' => 'inputsize', 'tabindex' =>'12'));?>
           
			<?php echo $this->Form->input('provinces_id',array('label'=>'Provincia','id'=>'provinces','empty' => '-- Seleccione --','class' => 'inputsize', 'tabindex' =>'13'));?>
                 
			 
			 <?php echo $this->Form->input('charters_id',array('id'=>'charters','empty' => '-- Seleccione --', 'label'=> 'Fuero', 'tabindex' =>'14')); ?>
			 <?php echo $this->Form->input('placements_id',array('id'=>'placements','empty' => '-- Seleccione --', 'label'=> 'Depto. Judicial o Circunscripción','class' => 'inputsize', 'tabindex' =>'15'));?>
			 <br/>
			 <?php echo $this->Form->input('courts_id',array('id'=>'courts','empty' => '-- Seleccione --', 'label'=> 'Juzgado','class' => 'inputsize', 'tabindex' =>'16'));?>
             <?php echo $this->Form->input('Causes.secretaries_id',array('id'=>'secretaries','empty' => '-- Seleccione --', 'label'=> 'Secretaría','class' => 'inputsize', 'tabindex' =>'17'));?>
             <?php echo $this->Form->input('Causes.nro_causa', array('label'=>'Nº de Causa', 'tabindex' =>'19'));?>
             <?php echo $this->Form->input('Causes.descripcion', array('label'=>'Descripción <br/>(opcional)', 'tabindex' =>'20'));?>
			 
			</span>
            </fieldset>
	    </div>
		
	    <div style="width: 500px; padding-top:1px; float:left; padding-left: 10px;">
                
 
            <fieldset>    
            <h5 style="margin-top: 0px; margin-bottom: 8px;"><legend><?php __('Fotos'); ?></legend></h5>
		<span style="padding-left: 60px;">
<!--                    ***********************************************************************************************-->
<!--                aca armo los divs para subir las imagenes   EXTERIORES -->

		<fieldset>
                <h5 style="margin-top: 0px; margin-bottom: 8px; height: 350px;"><legend><?php __('Exteriores'); ?></legend></h5>

<!--       ***********************************************************************************************-->
<!--       aca armo los divs para subir las imagenes   INTERIORES Y MOTOR -->
              </fieldset>
                    <fieldset>
			<h6 style="margin-top: 0px; margin-bottom: 8px; height: 200px;"><legend><?php __('Interior y Motor'); ?></legend></h5>
                        <?php 
                        echo  $this->Form->hidden( 'uploads.perfil_derecho', array( 'value' =>'') );
                        echo  $this->Form->hidden( 'uploads.perfil_izquierdo', array( 'value' =>'') );
                        echo  $this->Form->hidden( 'uploads.frente', array( 'value' =>'') );
                        echo  $this->Form->hidden( 'uploads.baul', array( 'value' =>'') );
                        echo  $this->Form->hidden( 'uploads.interior', array( 'value' =>'') );
                        echo  $this->Form->hidden( 'uploads.motor', array( 'value' =>'') );
                        ?>                                  
                    </fieldset>
              </fieldset>
		</div>
		 <div style="width: 450px; padding-top:1px; float:left; padding-left: 10px;">
            <fieldset>    
            <h5 style="margin-top: 0px; margin-bottom: 8px;"><legend><?php __('Ubicación y Estado'); ?></legend></h5>
		    <span style="padding-left: 60px;">
            <?php echo $this->Form->input('police_states_id',array('label'=>'Estado','type'=>'select','options'=>$states,'empty'=>'--Seleccione--','class' => 'inputsize2', 'tabindex' =>'30'));?>
		    <div id="divout">
			<?php echo $this->Form->input('desposits_id',array('label'=>'Depósito','options'=>$desposits,'type'=>'select','empty'=>'--Seleccione--','class' => 'inputsize2', 'tabindex' =>'31'));?>
		    </div>
			<?php echo $this->Form->input('observaciones ',array('tabindex' =>'32'));?>
		    
		    </span>
            </fieldset>
		</div>
		
		  
        <div style="clear:both;">	   
	   <?php echo $form->submit('Guardar', array('onClick' => 'sendForm().returnValue = false; return false;')); ?>
            <?php echo $this->Form->end();?>
           
    </div>
              
                    
                    
            
       <?php     
        $options1 = array('url' => 'update_select', 'update' => 'models');
        echo $ajax->observeField('brands', $options1);

        $options2 = array('url' => 'update_jurisdictions', 'update' => 'provinces');
        echo $ajax->observeField('jurisdictions', $options2);

        $options3 = array('url' => 'update_provinces', 'update' => 'charters');
        echo $ajax->observeField('provinces',$options3);
    
        $options4 = array('url' => 'update_placements', 'update' => 'placements');
        echo $ajax->observeField('charters',$options4);
    
        $options5 = array('url' => 'update_courts', 'update' => 'courts');
        echo $ajax->observeField('placements',$options5);
    
        $options6 = array('url' => 'update_secretaries', 'update' => 'secretaries');
        echo $ajax->observeField('courts',$options6);

        $options7 = array('url' => 'update_image', 'update' => 'id_perfil_derecho');
        echo $ajax->observeForm('uploadsPerfilDerecho', $options7);

        $options8 = array('url' => 'update_image', 'update' => 'id_perfil_izquierdo');
        echo $ajax->observeField('uploadsPerfilIzquierdo', $options8);

        $options9 = array('url' => 'update_image', 'update' => 'id_frente');
        echo $ajax->observeField('uploadsFrente', $options9);

        $options10 = array('url' => 'update_image', 'update' => 'id_baul');
        echo $ajax->observeField('uploadsBaul', $options10);

        $options11 = array('url' => 'update_image', 'update' => 'id_interior');
        echo $ajax->observeField('uploadsInterior', $options11);

        $options12 = array('url' => 'update_image', 'update' => 'id_motor');
        echo $ajax->observeField('uploadsMotor', $options12);
        ?>
        </div> 
                    
  <!-- aca va las divs con posicion absolute que quede como dentro del Form                    -->
<div id="img_fija_p-derecho">
                   <div id="perfilderecho">
                    <?php      			  
                    echo $html->image('perfil_derecho.jpg',
                                array('alt' =>'Perfil derecho',
                                     'title' => 'Perfil derecho',
                                      'width'=>'50',
                                       'height'=>'35')
                                );
                   ?>
                </div>
               <div id="img_movil">
                            <form id="form" name="form_imagen_derecha" method="post" action="/prona_01/trunk/masters/sube_img_server" enctype="multipart/form-data" target="iframe">
                            <input type="file" id="derecha" name="derecha" onChange="envia_img();"/>
                            </form>
                     <p id="message">Perfil derecho.</p>               
               </div>
               <div id="thumbails">
                 <iframe style="display: none;" name="iframe"></iframe>  
                 <img style=" height:70px; width: 100px;" id="image_derecha" /><br /><br />
                   </div>
               </div>  
  <div id="img_fija_p-izquierdo">
                   <div id="perfilderecho">
                  <?php                   
                    echo $html->image('perfil_izquierdo.jpg',
                                array('alt' =>'Perfil izquierdo',
                                     'title' => 'Perfil izquierdo',
                                      'width'=>'50',
                                       'height'=>'35')
                                );
                   ?>
                </div>
               <div id="img_movil">
                            <form id="form" name="form_imagen_izquierda" method="post" action="/prona_01/trunk/masters/sube_img_server" enctype="multipart/form-data" target="iframe">
                            <input type="file" id="izquierda" name="izquierda" onChange="envia_img_iz();"/>
                            </form>
                     <p id="message_iz">Perfil izquierdo.</p>               
               </div>
               <div id="thumbails">
                 <iframe style="display: none;" name="iframe"></iframe>  
                 <img style=" height:70px; width: 100px;" id="image_izquierda" /><br /><br />
                   </div>
               </div>  
    <div id="img_fija_p-frente">
                   <div id="perfilderecho">
                  <?php                   
                    echo $html->image('frente.jpg',
                                array('alt' =>'Frente',
                                     'title' => 'Frente',
                                      'width'=>'50',
                                       'height'=>'35')
                                );
                   ?>
                </div>
               <div id="img_movil">
                            <form id="form" name="form_imagen_frente" method="post" action="/prona_01/trunk/masters/sube_img_server" enctype="multipart/form-data" target="iframe">
                            <input type="file" id="frente" name="frente" onChange="envia_img_fr();"/>
                            </form>
                     <p id="message_fr">Frente.</p>               
               </div>
               <div id="thumbails">
                 <iframe style="display: none;" name="iframe"></iframe>  
                 <img style=" height:70px; width: 100px;" id="image_frente" /><br /><br />
               </div>  
    </div> 
      <div id="img_fija_p-baul">
                   <div id="perfilderecho">
                  <?php                   
                    echo $html->image('baul.jpg',
                                array('alt' =>'Frente',
                                     'title' => 'Frente',
                                      'width'=>'50',
                                       'height'=>'35')
                                );
                   ?>
                </div>
               <div id="img_movil">
                            <form id="form" name="form_imagen_baul" method="post" action="/prona_01/trunk/masters/sube_img_server" enctype="multipart/form-data" target="iframe">
                            <input type="file" id="baul" name="baul" onChange="envia_img_ba();"/>
                            </form>
                     <p id="message_ba">Baul.</p>               
               </div>
               <div id="thumbails">
                 <iframe style="display: none;" name="iframe"></iframe>  
                 <img style=" height:70px; width: 100px;" id="image_baul" /><br /><br />
               </div>  
    </div> 
  
    <div id="img_fija_p-interior">
                   <div id="perfilderecho">
                  <?php                   
                    echo $html->image('interior.jpg',
                                array('alt' =>'Interior',
                                     'title' => 'Interior',
                                      'width'=>'50',
                                       'height'=>'35')
                                );
                   ?>
                </div>
               <div id="img_movil">
                            <form id="form" name="form_imagen_interior" method="post" action="/prona_01/trunk/masters/sube_img_server" enctype="multipart/form-data" target="iframe">
                            <input type="file" id="interior" name="interior" onChange="envia_img_in();"/>
                            </form>
                     <p id="message_in">Interior.</p>               
               </div>
               <div id="thumbails">
                 <iframe style="display: none;" name="iframe"></iframe>  
                 <img style=" height:70px; width: 100px;" id="image_interior" /><br /><br />
               </div>  
    </div> 
  
          <div id="img_fija_p-motor">
                   <div id="perfilderecho">
                  <?php                   
                    echo $html->image('motor.jpg',
                                array('alt' =>'Motor',
                                     'title' => 'Motor',
                                     'width'=>'50',
                                     'height'=>'35')
                                );
                   ?>
                </div>
               <div id="img_movil">
                            <form id="form" name="form_imagen_motor" method="post" action="/prona_01/trunk/masters/sube_img_server" enctype="multipart/form-data" target="iframe">
                            <input type="file" id="motor" name="motor" onChange="envia_img_mo();"/>
                            </form>
                     <p id="message_mo">Motor.</p>               
               </div>
               <div id="thumbails">
                 <iframe style="display: none;" name="iframe"></iframe>  
                 <img style=" height:70px; width: 100px;" id="image_motor" /><br /><br />
               </div>  
    </div> 